package alo;

/**
 * @ClassName t14
 * @Description TODO
 * @Author Fanxc
 * @DATE 2021/4/21 14:25
 * @Version 1.0
 */
public class t14 {
    public int getLongestPalindrome(String A, int n) {
        if (A==null||n<=0)return 0;
        int l;
        int r;
        int res=0;
        char[] ch = A.toCharArray();
        for (int i = 0; i < n; i++) {
            l=i;
            r=i;
            while (l-1>=0&&ch[l-1]==ch[i])l--;
            while (r+1<n&&ch[r+1]==ch[i])r++;
            while (l-1>=0&&r+1<n&&ch[l-1]==ch[r+1]){
                l--;
                r++;
            }
            res=Math.max(res,r-l+1);
        }
        return res;
    }
}
